package com.adjy.pathbuilders.objects.button;

import static com.adjy.pathbuilders.commons.Preconditions.checkNotNull;
import android.graphics.Paint;

import com.adjy.pathbuilders.objects.button.listeners.ButtonListener;
import com.adjy.pathbuilders.rendering.GameCanvas;

public class PaintButton extends Button {
	
	private Paint rectPaint;
	private String text;
	private Paint textPaint;
	
	
	public PaintButton(int x, int y, int width, int height, ButtonListener listener,
			String text, Paint rectPaint, Paint textPaint) {
		super(x, y, width, height, listener);
		checkNotNull(text, "text must not be null.");
		checkNotNull(rectPaint, "rectPaint must not be null.");
		checkNotNull(textPaint, "textPaint must not be null.");
		
		this.rectPaint = rectPaint;
		this.text = text;
		this.textPaint = textPaint;
	}

	@Override
	public void render(GameCanvas canvas, float timeElapsed) {
		canvas.drawRoundRect(x, y, width, height, rectPaint, 10, 10);
		canvas.drawText(text,
				(int) (x + width / 2 - textPaint.measureText(text) / 2),
				(int) (y + height / 2), textPaint);
	}
}
